/* eslint-disable eqeqeq */
import { Button, Form, Input, TextArea, Toast } from "antd-mobile";
import React from "react";
import { feedback } from "../API/feedbackAPI";
import { useHistory } from "react-router-dom";
import Header from "../../Header";

export default function FeedBack() {
  const history = useHistory();

  const onFinish = async (values: any) => {
    // console.log(values);
    let res = await feedback(values);
    // console.log(res);
    if (res.data.code == 200) {
      Toast.show({
        content: res.data.msg,
      });
      history.push("/mine/feedbacklist");
    } else {
      Toast.show({
        content: res.data.msg,
      });
    }
  };

  return (
    <>
    <Header title="意见反馈"></Header>
    <div className="xz-content"> 
      <Form
        onFinish={onFinish}
        footer={
          <Button block type="submit" color="primary" size="large">
            提交
          </Button>
        }
      >
        <Form.Item
          name="title"
          label="反馈标题"
          rules={[{ required: true, message: "反馈标题不能为空" }]}
        >
          <Input placeholder="请输入反馈标题" />
        </Form.Item>
        <Form.Item
          name="content"
          label="反馈内容"
          rules={[{ required: true, message: "反馈内容不能为空" }]}
        >
          <TextArea
            placeholder="请输入反馈内容"
            maxLength={150}
            rows={4}
            showCount
          />
        </Form.Item>
      </Form>
    </div>
    </>
  );
}
